package com.sdx.console.order.entity;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.ibeetl.admin.core.annotation.Dict;
import com.ibeetl.admin.core.entity.BaseEntity;
import com.ibeetl.admin.core.util.ValidateConfig;
import com.sdx.common.utils.Utils;
import lombok.Data;
import org.beetl.sql.core.annotatoin.AutoID;

import javax.validation.constraints.NotNull;
import java.util.Date;

/*
*
* gen by Spring Boot2 Admin 2019-04-09
*/
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
@Data
public class FinOrder extends BaseEntity{

    //订单编号 编号规则，order_type+YYMMdd+随机四位数
    @NotNull(message = "ID不能为空", groups =ValidateConfig.UPDATE.class)
    @AutoID
    private String orderNo ;

    //订单名称
    private String orderName ;

    //会员id
    private String userId ;

    //产品类型 985 表sale_product[product_type]
    private Integer orderType ;

    //产品id 表sale_product[product_id]
    private String orderId ;

    //购买数量
    private Integer buyCount ;

    //总价 单位分
    private Integer totalMoney ;

    //联系人
    private String contactPerson ;

    //联系电话
    private String contactPhone ;

    //寄送地址
    private String address ;

    //邮递方式 1、顺丰快递
    @Dict(type = "EXPRESS_TYPE")
    private Integer express ;

    //客户备注
    private String customerMemo ;

    //交易备注
    private String orderMemo ;

    //订单处理状态 1、新增，2、已发货，3、已完结
    private Integer handleStatus ;

    //快递单号
    private String expressNum ;

    //处理人
    private Integer updatedBy ;

    //处理人名称
    private String updatedName ;

    //处理人时间
    private Date updatedTime ;

    //处理备注
    private String handleMemo ;

    private Date sendTime;

    private String updatedTimeQuery;

    private Date updatedTimeStart;

    private Date updatedTimeEnd;

    private String payTimeQuery;

    private Date payTimeStart;

    private Date payTimeEnd;

    public String getUpdatedTimeQuery() {
        return updatedTimeQuery;
    }

    public void setUpdatedTimeQuery(String updatedTimeQuery) {
        this.updatedTimeQuery = updatedTimeQuery;
        Date[] timePair = Utils.parseQueryTime(updatedTimeQuery);
        if (timePair!=null && timePair[0]!=null) {
            this.updatedTimeStart = timePair[0];
        }
        if (timePair!=null && timePair.length==2 && timePair[1]!=null) {
            this.updatedTimeEnd = timePair[1];
        }

    }

    public Date getUpdatedTimeStart() {
        return updatedTimeStart;
    }

    public void setUpdatedTimeStart(Date updatedTimeStart) {
        this.updatedTimeStart = updatedTimeStart;
    }

    public Date getUpdatedTimeEnd() {
        return updatedTimeEnd;
    }

    public void setUpdatedTimeEnd(Date updatedTimeEnd) {
        this.updatedTimeEnd = updatedTimeEnd;
    }

    public String getPayTimeQuery() {
        return payTimeQuery;
    }

    public void setPayTimeQuery(String payTimeQuery) {
        this.payTimeQuery = payTimeQuery;
        Date[] timePair = Utils.parseQueryTime(payTimeQuery);
        if (timePair!=null && timePair[0]!=null) {
            this.payTimeStart = timePair[0];
        }
        if (timePair!=null && timePair.length==2 && timePair[1]!=null) {
            this.payTimeEnd = timePair[1];
        }
    }

    public Date getPayTimeStart() {
        return payTimeStart;
    }

    public void setPayTimeStart(Date payTimeStart) {
        this.payTimeStart = payTimeStart;
    }

    public Date getPayTimeEnd() {
        return payTimeEnd;
    }

    public void setPayTimeEnd(Date payTimeEnd) {
        this.payTimeEnd = payTimeEnd;
    }
}
